package com.linb.pan.server.modules.user.converter;

import com.linb.pan.server.modules.file.entity.BPanUserFile;
import com.linb.pan.server.modules.user.context.*;
import com.linb.pan.server.modules.user.entity.BPanUser;
import com.linb.pan.server.modules.user.po.*;
import com.linb.pan.server.modules.user.vo.UserInfoVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(componentModel = "spring")
public interface UserConverter {


    UserRegisterContext userRegisterPO2UserRegisterContext(UserRegisterPO userRegisterPO);

    @Mapping(ignore = true, target = "password")
    BPanUser userRegisterContextToBPanUser(UserRegisterContext userRegisterContext);

    UserLoginContext userLoginPOToUserLoginContext(UserLoginPO userLoginPO);

    CheckUsernameContext checkUsernamePOToCheckUsernameContext(CheckUsernamePO checkUsernamePO);

    CheckAnswerContext checkAnswerPOToCheckAnswerContext(CheckAnswerPO checkAnswerPO);

    @Mapping(source = "po.newPassword", target = "password")
    ResetPasswordContext resetPasswordPOToResetPasswordContext(ResetPasswordPO po);

    ChangePasswordContext changePasswordPOToChangePasswordContext(ChangePasswordPO changePasswordPO);

    @Mapping(source = "user.username", target = "username")
    @Mapping(source = "userFile.fileId", target = "rootFileId")
    @Mapping(source = "userFile.filename", target = "rootFilename")
    UserInfoVO assembleUserInfoVO(BPanUser user, BPanUserFile userFile);

}
